//
//  ViewController.swift
//  AbstactFactoryDemo
//
//  Created by 好米有易 on 2017/9/28.
//  Copyright © 2017年 好米有易. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    /// 创建形状工厂
    let shapeFactory = FactoryProducer.getFactory(type:ProducerType.shape)
    
    /// 创建颜色工厂
    let colorFactory = FactoryProducer.getFactory(type:ProducerType.color)
    
    /// circle
    ///
    /// - Parameter sender: UIButton
    @IBAction func circle(_ sender: UIButton) {
        
      let circleShape = shapeFactory.getShape(type: .circle)
        
        circleShape.draw()
    }
    
    /// square
    ///
    /// - Parameter sender: UIButton
    @IBAction func square(_ sender: UIButton) {
        let squareShape = shapeFactory.getShape(type: .square)
        
        squareShape.draw()
    }
    
    /// rectangle
    ///
    /// - Parameter sender: UIButton
    @IBAction func rectangle(_ sender: UIButton) {
        
        let rectangleShape = shapeFactory.getShape(type: .rectangle)
        
        rectangleShape.draw()
    }
    
    /// red
    ///
    /// - Parameter sender: UIButton
    @IBAction func red(_ sender: UIButton) {
        
     let redColor = colorFactory.getColor(type: .red)
        redColor.fill()
    }
    
    /// green
    ///
    /// - Parameter sender: UIButton
    @IBAction func green(_ sender: UIButton) {
        let greenColor = colorFactory.getColor(type: .red)
        greenColor.fill()

    }
    
    /// blue
    ///
    /// - Parameter sender: UIButton
    @IBAction func blue(_ sender: UIButton) {
        let blueColor = colorFactory.getColor(type: .red)
            blueColor.fill()
    }
    
    
}

